<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
		"http://www.w3.org/TR/html4/strict.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<title>doh.robot TimeTextBox Test</title>

		<style>
			@import "../../../../util/doh/robot/robot.css";
		</style>

		<!-- required: dojo.js -->
		<script type="text/javascript" src="../../../../dojo/dojo.js"
			djConfig="isDebug: true, parseOnLoad: true"></script>
		<script type="text/javascript" src="../../helpers.js"></script>

		<script type="text/javascript">
			dojo.require("dijit.robotx");
			dojo.require("dojo.date.stamp");

			dojo.addOnLoad(function(){
				doh.robot.initRobot('../test_TimeTextBox.html');

				doh.register("TimeTextBox", [
					{
						name: "keyboard",
						timeout: 60000,
						runTest: function(){
							var d = new doh.Deferred(),
								w = dijit.byId('q1');
	
							// focus field, thus opening drop down		
							w.focus();
	
							// advance from 5:45PM to 6PM, and select
							doh.robot.keyPress(dojo.keys.DOWN_ARROW, 1000, {});
							doh.robot.keyPress(dojo.keys.ENTER, 500, {});
							
							doh.robot.sequence(d.getTestCallback(dojo.hitch(this, function(){
								var val = dojo.date.stamp.toISOString(w.get('value'), {selector: "time"});	
								doh.is(val, "T18:00:00", "should be 6PM");
							})), 500);
							return d;
						}
					},
					{
						name: "partial input",
						timeout: 60000,
						setUp: function(){
							// clear the field
							var w = dijit.byId('q2');
							w.set('value', null, false);
						},
						runTest: function(){
							var d = new doh.Deferred(),
								w = dijit.byId('q2');
	
							// focus field, thus opening drop down		
							w.focus();
	
							// close drop down
							doh.robot.keyPress(dojo.keys.ESCAPE, 1500, {});
							
							// do partial input
							doh.robot.typeKeys('12:', 1000, 600);

							doh.robot.sequence(d.getTestCallback(dojo.hitch(this, function(){
								doh.f(w.isValid(), 'fully invalid');
								doh.t(w._isValidSubset(), 'partially valid');
								doh.f(this.state == "Error", 'no error shown');
							})), 500);
							return d;
						}
					}
				]);

				doh.run();
			});
		</script>
	</head>
</html>
